"""
自建题库页面
"""
import time

from selenium.webdriver.common.by import By
from PAGE.base_page import BasePage
class IndexPage(BasePage):
    # 自建题库
    zijiantiku = (By.XPATH,'//*[@id="app"]/div/div[1]/div[2]/div[1]/div/ul/div[2]/li/ul/div[1]/a/li/span')
    # 试题列表
    question_list = (By.XPATH,'//*[@id="tab-first"]')
    # 草稿箱
    draft_box = (By.XPATH,'//*[@id="tab-second"]')
    # 已归档
    archive_box = (By.XPATH,'//*[@id="tab-third"]')
    # 添加试题
    add_question = (By.XPATH,'//*[@id="pane-first"]/div[1]/div/button[1]/span')
    # 点击自建题库
    def click_zijiantiku(self):
        self.driver.find_element(*self.zijiantiku).click()
    # 点击试题列表
    def click_question_list(self):
        self.driver.find_element(*self.question_list).click()
    # 点击草稿箱
    def click_draft_box(self):
        self.driver.find_element(*self.draft_box).click()
    # 点击已归档
    def click_archive_box(self):
        self.driver.find_element(*self.archive_box).click()
    # 点击添加试题
    def click_add_question(self):
        self.driver.find_element(*self.add_question).click()


class AddQuestionPage(BasePage):
    # 项目
    xiang_mu = (By.XPATH,'//*[@id="app"]/div/div[2]/section/div/div[2]/div/div/section/div/form/div/div[1]/div/div/div[1]/div/div/div[1]/div/input')
    # 题型
    ti_xing = (By.XPATH,'//*[@id="app"]/div/div[2]/section/div/div[2]/div/div/section/div/form/div/div[1]/div/div/div[2]/div/div/div[1]/input')
    # 难度
    nan_du = (By.XPATH,'//*[@id="app"]/div/div[2]/section/div/div[2]/div/div/section/div/form/div/div[1]/div/div/div[3]/div/div/div/input')
    # 分数
    fen_shu = (By.XPATH,'//*[@id="app"]/div/div[2]/section/div/div[2]/div/div/section/div/form/div/div[1]/div/div/div[4]/div/div/div/input')
    # 题干
    ti_gan1 = (By.XPATH,'//*[@id="app"]/div/div[2]/section/div/div[2]/div/div/section/div/form/div/div[2]/div/div/div[1]/div/div/div[1]/div[1]')
    ti_gan2 = (By.XPATH,'/html/body/div[1]/div/div[2]/section/div/div[2]/div/div/section/div/form/div/div[2]/div/div/div[1]/div/div/div[1]/div[2]/div[2]/div[1]')
    #答案解析1
    da_an_jie_xi1 = (By.XPATH,'//*[@id="app"]/div/div[2]/section/div/div[2]/div/div/section/div/form/div/div[2]/div/div/div[3]/div/div/div[1]/div[1]')
    #答案解析2
    da_an_jie_xi2 = (By.XPATH,'/html/body/div[1]/div/div[2]/section/div/div[2]/div/div/section/div/form/div/div[2]/div/div/div[3]/div/div/div[1]/div[2]/div[2]/div[1]')
    # 更多设置
    geng_duo_she_zhi = (By.XPATH,'//*[@id="app"]/div/div[2]/section/div/div[2]/div/div/section/div/form/div/div[2]/div/div/div[4]')
    # 单选选项列表
    dan_xuan_xuan_xiang_list = (By.XPATH,'//*[@id="app"]/div/div[2]/section/div/div[2]/div/div/section/div/form/div/div[2]/div/div/div[2]')
    #添加选项按钮
    add_xuan_xiang_button = (By.XPATH,'//*[@id="app"]/div/div[2]/section/div/div[2]/div/div/section/div/form/div/div[2]/div/div/div[2]/div[1]/button[1]')

    # 点击项目
    def click_xiang_mu(self):
        self.driver.find_element(*self.xiang_mu).click()
    # 点击题型
    def click_ti_xing(self):
        self.driver.find_element(*self.ti_xing).click()
    # 点击难度
    def click_nan_du(self):
        self.driver.find_element(*self.nan_du).click()
    # 点击分数
    def click_fen_shu(self):
        self.driver.find_element(*self.fen_shu).click()

    # 点击题干并输入内容
    def click_ti_gan_and_input_content(self):
        self.driver.find_element(*self.ti_gan1).click()
        self.driver.find_element(*self.ti_gan2).click()
        self.driver.find_element(*self.ti_gan2).send_keys('测试题目'+str(int(time.time())))

    # 点击答案解析并输入内容
    def click_da_an_jie_xi_and_input_content(self):
        self.driver.find_element(*self.da_an_jie_xi1).click()
        self.driver.find_element(*self.da_an_jie_xi2).click()
        self.driver.find_element(*self.da_an_jie_xi2).send_keys('测试答案解析'+str(int(time.time())))

    # 点击更多设置
    def click_geng_duo_she_zhi(self):
        self.driver.find_element(*self.geng_duo_she_zhi).click()
    # 操作单选选项列表
    def operate_dan_xuan_xuan_xiang_list(self,num):
        # 点击添加选项按钮
        for i in range(int(num)):
            self.driver.find_element(*self.dan_xuan_xuan_xiang_list).find_element(By.CSS_SELECTOR,'a').click()
